#ifndef LEETCODE_CN_CPP_PROBLEMS_70_H
#define LEETCODE_CN_CPP_PROBLEMS_70_H

namespace problem_70
{

class Solution
{
public:
    int climbStairs(int n)
    {
        if (n <= 2)
        {
            return n;
        }
        int pre2, pre1 = 1, cur = 2;
        n -= 2;
        while (n > 0)
        {
            pre2 = pre1;
            pre1 = cur;
            cur = pre1 + pre2;
            n -= 1;
        }
        return cur;
    }
};

} // namespace problem_70

#endif //LEETCODE_CN_CPP_PROBLEMS_70_H
